<template>
  <view :class="['yy-tag', Typeclass, customClass]" :style="{ background: color }">
    <slot />
  </view>
</template>

<script>
  export default {
    name: 'yy-tag',
    props: {
      type: {
        type: String,
        default: 'default',
        validator: (v) => {
          return ['default', 'org', 'yellow'].includes(v)
        }
      },
      customClass: { type: String },
      // 背景颜色 背景颜色优先级 > type
      color: {
        type: String
      }
    },
    data() {
      return {}
    },
    computed: {
      // 背景颜色优先级 > type
      Typeclass() {
        if (this.type) {
          return 'yy-tag-' + this.type
        }
        return ''
      }
    }
  }
</script>
<style lang="scss" scoped>
  .yy-tag {
    vertical-align: middle;
    display: inline-block;
    color: #fff;
    font-size: 20rpx;
    font-weight: 500;
    border-radius: 4rpx;
    padding: 0 7rpx;
    min-width: 40rpx;
    text-align: center;
    height: 28rpx;
    line-height: 28rpx;
    &-default {
      background: #ffb415;
    }
    &-org {
      background: $org;
    }
    &-yellow {
      background: $yellow;
    }
  }
</style>
